Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

intl-format-cache

Package Overview
Dependencies
Maintainers
6
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-format-cache

A memoizer factory for Intl format constructors.

  • 4.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created

What is intl-format-cache?

The intl-format-cache npm package is a utility for caching instances of Intl formatters, such as Intl.DateTimeFormat, Intl.NumberFormat, and Intl.RelativeTimeFormat. This can improve performance by reusing formatter instances instead of creating new ones each time formatting is needed.

What are intl-format-cache's main functionalities?

Caching DateTimeFormat instances

This feature allows you to cache instances of Intl.DateTimeFormat. The code sample demonstrates how to create and reuse a DateTimeFormat instance for formatting dates in 'en-US' locale.

const { getDateTimeFormat } = require('intl-format-cache');
const dateTimeFormat = getDateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
console.log(dateTimeFormat.format(new Date()));

Caching NumberFormat instances

This feature allows you to cache instances of Intl.NumberFormat. The code sample demonstrates how to create and reuse a NumberFormat instance for formatting numbers as currency in 'en-US' locale.

const { getNumberFormat } = require('intl-format-cache');
const numberFormat = getNumberFormat('en-US', { style: 'currency', currency: 'USD' });
console.log(numberFormat.format(123456.789));

Caching RelativeTimeFormat instances

This feature allows you to cache instances of Intl.RelativeTimeFormat. The code sample demonstrates how to create and reuse a RelativeTimeFormat instance for formatting relative time in 'en-US' locale.

const { getRelativeTimeFormat } = require('intl-format-cache');
const relativeTimeFormat = getRelativeTimeFormat('en-US');
console.log(relativeTimeFormat.format(-1, 'day'));

Other packages similar to intl-format-cache

Keywords

FAQs

Package last updated on 24 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc